package com.wsz.eduservice.controller;

import com.wsz.commonutils.R;
import com.wsz.eduservice.pojo.subject.OneSubject;
import com.wsz.eduservice.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

@Api(tags = "课程管理")
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {

    @Autowired
    SubjectService subjectService;

    @ApiOperation("上传excel文件添加课程分类")
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file){
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }
    @ApiOperation("获取全部课程分类")
    @GetMapping("/getAllSubject")
    public R getAllSubject(){
        List<OneSubject> list = subjectService.getAllOneSubject();
        return R.ok().data("list",list);
    }

}
